import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const routes = [
	{
		path: '/',
		name: 'Home',
		component: () => import('../views/Home.vue'),
		meta: {
			title: '首页',
			requireAuth: true
		}
	},{
		path: '/login',
		name: 'login',
		meta: {
            title: '登录'
        },
		component: () => import('../views/login.vue')
	},{
		path: '/detail/:id',
		name: 'detail',
		meta: {
            title: '订单详情',
			requireAuth: true
        },
		component: () => import('../views/detail.vue'),
	},{
		path: '/public/:id',
		name: 'detail',
		meta: {
            title: '订单详情',
			requireAuth: true
        },
		component: () => import('../views/publicOrder.vue'),
	},{
		path: '/order/:mode/:id',
		name: 'order',
		meta: {
            title: '新增订单',
			requireAuth: true
        },
		component: () => import('../views/order.vue'),
	},{
		path: '/print/:id',
		name: 'print',
		meta: {
            title: '打印方案',
			requireAuth: true
        },
		component: () => import('../views/print.vue'),
	},
	{
		path: '*',
		name: 'error',
		meta: {
            title: '404'
        },
		component: () => import('../views/error.vue')
	}
]
const router = new VueRouter({
	mode: 'history',
	base: process.env.BASE_URL,
	routes
})
export default router
